<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center myInformation_flex_0"
			:style="{ height: (64 + StatusBarRpx) + 'rpx', paddingTop: StatusBarRpx + 'rpx' }">
			<view class='flex flex-wrap align-center justify-between flex-sub myInformation_fd0_0'>
				<view class='flex flex-wrap align-center myInformation_fd0_0_c0'
					@tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  myInformation_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center'>
					<text class='myInformation_fd0_0_c1_c0'>我的资料</text>
				</view>
				<view class='flex flex-wrap align-center myInformation_fd0_0_c2'>
					<text class='myInformation_fd0_0_c2_c0'></text>
				</view>
			</view>

		</view>
		<view :style="{ height: (64 + StatusBarRpx) + 'rpx' }"></view>

		<view class="flex flex-direction flex-wrap align-stretch myInformation_flex_1">
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0'>
				<text class='myInformation_fd1_0_c0'>头像</text>
				<view class="upload position-relative">

					<image class=" myInformation_fd1_0_c1_image" mode="aspectFill"
						@tap="soloChooseImage('avatar', 'avatar', userInfo, userInfo)"
						:src="userInfo.avatar ? userInfo.avatar : STATIC_URL + '82.png'"></image>
				</view>
			</view>
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0'>
				<text class='myInformation_fd1_0_c0'>用户名</text>
				<input class='flex-sub myInformation_fd1_2_c1' :disabled="true" type="text" placeholder="张怀民" confirm-type="done"
					:maxlength="-1" placeholder-style="color:rgba(153, 153, 153, 1);font-size:20rpx"
					v-model="userInfo.nickname" />
			</view>
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0'
				@tap.stop="pickerDiy1683966462102 = true">
				<text class='myInformation_fd1_0_c0'>性别</text>
				<view class='flex flex-wrap align-center'>
					<text class='myInformation_fd1_1_c1_c0' v-if="userInfo.gender != '0' && userInfo.gender != '1' && userInfo.gender != '2'">请选择性别</text>
					<text
						class='myInformation_fd1_1_c1_c0_1'>{{sex_options[userInfo.gender].name}}</text>
					<!-- <text
						class='myInformation_fd1_1_c1_c0_1' v-if="userInfo.sex == '2'">女</text> -->
					<text class='fu-iconfont2  myInformation_fd1_1_c1_c1'>&#xE78E;</text>
				</view>
			</view>
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0' @tap.stop="handleJumpDiy"
				data-type="navigateTo">
				<text class='myInformation_fd1_0_c0'>小区名称</text>
				<input class='flex-sub myInformation_fd1_2_c1' type="text" placeholder="小区名称" confirm-type="done"
					:maxlength="17" placeholder-style="color:rgba(153, 153, 153, 1);font-size:20rpx"
					v-model="userInfo.cell_name" />
			</view>
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0'
				@tap.stop="pickerDiy1684137696643 = true">
				<text class='myInformation_fd1_0_c0'>生日</text>
				<input class='flex-sub myInformation_fd1_2_c1' type="text" placeholder="请选择生日" confirm-type="done"
					:maxlength="30" :disabled='true' placeholder-style="color:rgba(153, 153, 153, 1);font-size:20rpx"
					v-model="userInfo.birthday" />
				<text class='fu-iconfont2  myInformation_fd1_1_c1_c1'>&#xE78E;</text>
			</view>
			<view class='flex flex-wrap align-center justify-between myInformation_fd1_0'>
				<text class='myInformation_fd1_0_c0'>当前级别</text>
				<text class='myInformation_fd1_3_c1' v-if="userInfo.account_type == 1">体验账号</text>
				<text class='myInformation_fd1_3_c1' v-if="userInfo.account_type == 2">正式账号</text>
			</view>
			
			<button class='myInformation_fd1_12' @tap.stop="setUserInfoFunc()">保存</button>
		</view>


		<!--选择性别开始 -->
		<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1683966462102"
			:value.sync='userInfo.gender' :options='sex_options' mode='selector' :mask-show='true' :timeout='true'
			:picker-height='88' default-type='value' :default-props='{ "label": "name", "value": "value" }'>
			<template #picker-header>
				<view class='flex flex-wrap align-center justify-between myInformation_picker2_0'>
					<text @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
					<text>选择性别</text>
					<text class='myInformation_picker2_0_c2'
						@tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
				</view>
			</template>
		</benben-picker>
		<!--选择性别结束 -->
		<!--选择日期开始 -->
		<benben-picker ref="benbenWritePickerCodepicker3" :visible.sync="pickerDiy1684137696643"
			:value.sync='userInfo.birthday' mode='date' :picker-height='88' :current='true' :mask-show='true'
			fields='day' :timeout='true' start-year='1950-01-01' end-year='现在'>
			<template #picker-header>
				<view class='flex flex-wrap align-center justify-between myInformation_picker3_0'>
					<text @tap="$refs.benbenWritePickerCodepicker3.cancel()">取消</text>
					<text>选择生日</text>
					<text class='myInformation_picker3_0_c2'
						@tap="$refs.benbenWritePickerCodepicker3.pickerConfirm()">确认</text>
				</view>
			</template>
		</benben-picker>
		<!--选择日期结束 -->


	</view>
</template>
<script>
	import UploadImage from '@/common/utils/upload-image.js'
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"pickerDiy1684137696643": false,
				"pickerDiy1683966462102": false,
				"fd1_0_c1id": "",
				"fd1_8_c1_c0": "",
				"fd1_8_c1_c0id": "",
				"fd1_9_c1_c0": "",
				"fd1_9_c1_c0id": "",
				"fd1_10_c1_c0": "",
				"fd1_10_c1_c0id": "",
				"fd1_11_c1_c0": "",
				"fd1_11_c1_c0id": "",
				"userInfo": {
					"gender": 1,
					"invite_code": "",
					"address": "",
					"address_code": "",
					"address_citycode": "",
					"id": "",
					"lastid": "",
					"user_nickname": "",
					"mobile": "",
					"user_name": "",
					"head_img": "",
					"birthday": "",
					"is_finger": "",
					"user_money": "",
					"freeze_money": "",
					"withdrawal_money": "",
					"score": "",
					"empirical": "",
					"invoice_title": "",
					"invoice_company_title": "",
					"total_consumption_money": "",
					"sex": "",
					"create_time": "",
					"phone": "",
					"online": "",
					"_mobile": "",
					"coupon": "",
					"age": "",
					"collection_count": "",
					"browse_count": "",
					"certified": "",
					"invite": []
				},
				"sex_options": [{
					"name": "保密",
					"value": "0",
					"image": ""
				}, {
					"name": "男",
					"value": "1",
					"image": ""
				}, {
					"name": "女",
					"value": "2",
					"image": ""
				}],
				"user": {
					"userinfo": {
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"isSet": false,
				"telAndName": {
					"mobile": "",
					"name": ""
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.queryUserInfoFunc();
		},
		onUnload() {
			
		},
		onReady() {

		},
		onShow() {
		
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//上传单图、多图方法
			soloChooseImage(id, path, obj, obj1, fnName = false) {
				let self = this
				if (!obj) obj = this
				if (!obj1) obj1 = this
				if (self.uploading) {
					return
				}
				// 从相册中选择图片
				uni.chooseImage({
					count: 1, // 默认3
					sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
					success: function(res) {
						self.uploading = true
						// 开始上传
						new UploadImage(res.tempFiles, {
							complete: function(res) {
								console.log('res------------------------------------------',res);
								self.uploading = false
								self.userInfo.avatar = res[0].path;
								// if (id) self.$set(obj, id, res[0].id)
								// if (path) self.$set(obj1, path, res[0].path)
								// if (fnName) self[fnName]()
							},
						})
					},
				})
			},
			//获取用户详细信息
			async queryUserInfoFunc() {
				//请求方法
				//数据验证

				let datauserInfo = await this.$api.post(global.apiUrls.post5c78c4772da97, {

				});

				if (datauserInfo.data.code != 1) {
					this.$message.info(datauserInfo.data.msg);
					return
				}
				let infouserInfo = datauserInfo.data;
				this.userInfo = infouserInfo.data;
			},
			//修改用户资料
			async setUserInfoFunc() {
				//请求方法
				//数据验证

				let datauser = await this.$api.post(global.apiUrls.post5cb54af125f1c, {
					avatar: this.userInfo.avatar,
					nickname: this.userInfo.nickname,
					gender: this.userInfo.gender,
					birthday: this.userInfo.birthday,
					cell_name: this.userInfo.cell_name,
					account_type: this.userInfo.account_type
				});

				if (datauser.data.code != 1) {
					this.$message.info(datauser.data.msg);
					return
				}
				this.$message.info(datauser.data.msg);
				let infouser = datauser.data;
				this.user = infouser.data
				setTimeout(() => {
					uni.navigateBack();
				}, 800)
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto !important;
	}

	.myInformation_flex_0 {
		background: #fff;
		width: 100%;
		height: 64rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.myInformation_fd0_0_c2_c0 {
		color: #333333;
		font-size: 20rpx;
		font-weight: 500;
		line-height: 50rpx;
	}

	.myInformation_fd0_0_c2 {
		height: 50rpx;
		width: 50rpx;
	}

	.myInformation_fd0_0_c1_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: #333333;
		line-height: 64rpx;
	}

	.myInformation_fd0_0_c0_c0 {
		font-size: 25rpx;
		color: #333;
	}

	.myInformation_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.myInformation_fd0_0 {
		padding: 0rpx 25rpx 0rpx 25rpx;
	}

	.myInformation_flex_1 {
		background: #fff;
		padding: 0rpx 25rpx 35rpx 25rpx;
		margin: 16rpx 25rpx 0;
		border-radius: 10rpx;
	}

	.myInformation_fd1_12 {
		background: #4087FD;
		border-radius: 34rpx;
		font-size: 25rpx;
		color: #fff;
		height: 68rpx;
		line-height: 68rpx;
		margin: 100rpx 0rpx 0rpx 0rpx;
	}

	.myInformation_fd1_11_c1_c0_image {
		width: 334rpx;
		height: 216rpx;
	}

	.myInformation_fd1_8_c1_c0_image {
		width: 400rpx;
		height: 252rpx;
	}

	.myInformation_fd1_8_c1_c0_icon {
		top: 0rpx;
		right: 0rpx;
		z-index: 10;
		color: #ff5536;
	}

	.myInformation_fd1_8_c0_c0 {
		color: #000000;
		font-size: 32rpx;
		font-weight: 700;
		line-height: 52rpx;
	}

	.myInformation_fd1_8_c0 {
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.myInformation_fd1_8 {
		margin: 0rpx 0rpx 32rpx 0rpx;
	}

	.myInformation_fd1_3_c1_1 {
		font-size: 20rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.myInformation_fd1_3_c1 {
		font-size: 20rpx;
		font-weight: 400;
		color: #333333;
	}

	.myInformation_fd1_2_c1 {
		font-size: 20rpx;
		font-weight: 400;
		color: #333;
		text-align: right;
		margin: 0rpx 0rpx 0rpx 20rpx;
	}

	.myInformation_fd1_1_c1_c1 {
		font-size: 15rpx;
		margin: 0rpx 0rpx 0rpx 20rpx;
	}

	.myInformation_fd1_1_c1_c0_1 {
		font-size: 20rpx;
		color: var(--benbenFontColor1);
		text-align: right;
	}

	.myInformation_fd1_1_c1_c0 {
		font-size: 20rpx;
		color: rgba(153, 153, 153, 1);
		text-align: right;
	}

	.myInformation_fd1_0_c1_image {
		width: 55rpx;
		height: 55rpx;
		border-radius: 50%;
	}

	.myInformation_fd1_0_c0 {
		font-size: 20rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
	}

	.myInformation_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 25rpx 0rpx 25rpx 0rpx;
	}

	.myInformation_picker2_0_c2 {
		color: #4087FD;
		font-size: 25rpx;
	}

	.myInformation_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 25rpx 0rpx 25rpx;
		line-height: 64rpx;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		font-size: 25rpx;
	}

	.myInformation_picker3_0_c2 {
		color: #4087FD;
		font-size: 25rpx;
	}

	.myInformation_picker3_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 25rpx 0rpx 25rpx;
		line-height: 64rpx;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		font-size: 25rpx;
	}
</style>